package thread;
//中断一个线程
public class ThreadDemo06 {
    public static boolean isQuit = false;   //通过共享标记中断线程
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            while(!isQuit){
                System.out.println(Thread.currentThread().getName() + "：别管我，我忙着转账！");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName()  + "：好险呀！险些误了大事！");
        }, "李四");

        System.out.println(Thread.currentThread().getName() + "：让李四开始转账");
        thread.start();
        Thread.sleep(10 * 1000);
        System.out.println(Thread.currentThread().getName() + "：老板来电话了，赶紧通知李四对方是骗子！");
        isQuit = true;
    }
}
